package com.multidisplay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.multidisplay.mapper.DisplayListMapper;
import com.multidisplay.mapper.VideoDisareaMapper;
import com.multidisplay.po.DisplayList;
import com.multidisplay.po.VideoDisarea;
import com.multidisplay.service.DisplayListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("DisplayListService")
public class DisplayListServiceImpl implements DisplayListService {
    @Resource
    private DisplayListMapper displayListMapper;

    @Override
    public void add(DisplayList displayList) {
        displayListMapper.insert(displayList);
    }

    @Override
    public void delById(int id) {
        QueryWrapper<DisplayList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);

        displayListMapper.delete(queryWrapper);
    }

    @Override
    public void delByBdId(int bdId) {
        QueryWrapper<DisplayList> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("bdId",bdId);

        displayListMapper.delete(queryWrapper);
    }

    @Override
    public List<DisplayList> selectById(int id) {
        QueryWrapper<DisplayList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        List<DisplayList> displayLists = displayListMapper.selectList(queryWrapper);
        return displayLists;
    }

    @Override
    public List<DisplayList> selectByVdId(int vdId) {
        QueryWrapper<DisplayList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("vdId",vdId);
        List<DisplayList> displayLists = displayListMapper.selectList(queryWrapper);
        return displayLists;
    }

    @Override
    public List<DisplayList> selectAll() {
        List<DisplayList> displayLists = displayListMapper.selectList(null);
        return displayLists;
    }

    @Override
    public void update(DisplayList displayList) {
        displayListMapper.update(displayList,null);
    }
}
